from msvcrt import LK_LOCK

import requests
import kkl_config
import time
import json

class KAPI:
    def __init__(self):
        self.url = kkl_config.URL

    def kAPI(self,service_name,param):
        data = {
            "client_id": "6",
            "param": param,
            "timestamp": round(time.time() * 1000),
            "sign": "75179AC2107414E04D2623C1456A7BC2",
            "service_name": service_name,
            "token": kkl_config.Token.token
        }
        respone = requests.post(self.url,json=data)
        res = respone.json()
        kkl_config.prints(respone)
        print(json.dumps(res,ensure_ascii=False,indent=2))

if __name__ == "__main__":
    from scripts01.login01 import LoginApi
    LoginApi().loginMobile()
    service_name = "learnprod.MyCourseQryFacade.page"
    param = "{\"qry\":{\"subjectId\":-1,\"termId\":-1,\"pageIndex\":1,\"courseStatusList\":[-1],\"pageSize\":0}}"
    KAPI().kAPI(service_name,param)

